package com.only4play.httpapt.support.web;

import com.only4play.httpapt.support.api.JsonPlaceholderService;
import com.only4play.httpapt.support.api.impl.JsonPlaceholderServiceImpl;
import com.only4play.httpapt.support.config.JsonPlaceholderConfigStorage;
import com.only4play.httpapt.support.config.impl.JsonPlaceholderConfigStorageImpl;
import jakarta.annotation.PostConstruct;
import lombok.Getter;

/**
 * @author liyuncong
 * @version 1.0
 * @file JPConfiguration
 * @brief JPConfiguration
 * @details JPConfiguration
 * @date 2024-08-16
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-08-16               liyuncong          Created
 */
public class JPConfiguration {

    @Getter
    private static JsonPlaceholderService service;

    static {
        init();
    }

    /**
     * If you are using spring framework, you can use @PostConstruct annotation for instantiation.
     */
    public static void init() {
        // you can set customize config, http type, timeout, or other.
        JsonPlaceholderConfigStorage storage = new JsonPlaceholderConfigStorageImpl();

        JsonPlaceholderServiceImpl internalService = new JsonPlaceholderServiceImpl();
        internalService.setConfigStorage(storage);

        service = internalService;
    }
}
